; ===============================================================================================================================
; Description ...: Language listing tweak for Lime OCR
; Author ........: Nishad TR, Lime Consultants [nishad at limeconsultants.com] http://www.limeconsultants.com
; License........: GNU GPL v3
; Version........: 0.1 a
; ===============================================================================================================================

#include <File.au3>

; ===============================================================================================================================
; No TrayIcon please
; ===============================================================================================================================
AutoItSetOption ("TrayIconHide", 1)

; ===============================================================================================================================
; Cleaning previous langlist.txt
; ===============================================================================================================================
FileDelete ("langlist.txt")

; ===============================================================================================================================
; Taking input from
; ls.exe -m -1 tessdata\*.traineddata > lslang.txt
; ===============================================================================================================================

$templanglist = FileRead ("lslang.txt")

; ===============================================================================================================================
; Basic cleanup to get only xxx list
; ===============================================================================================================================

$templanglist = StringReplace ($templanglist ,"tessdata\", "" )
$templanglist = StringReplace ($templanglist ,".traineddata", "" )

; ===============================================================================================================================
; Find and add language details
; ===============================================================================================================================

$templanglist = StringReplace ($templanglist ,"aar,", "Afar=aar" )
$templanglist = StringReplace ($templanglist ,"abk,", "Abkhazian=abk" )
$templanglist = StringReplace ($templanglist ,"afr,", "Afrikaans=afr" )
$templanglist = StringReplace ($templanglist ,"aka,", "Akan=aka" )
$templanglist = StringReplace ($templanglist ,"amh,", "Amharic=amh" )
$templanglist = StringReplace ($templanglist ,"ara,", "Arabic=ara" )
$templanglist = StringReplace ($templanglist ,"arg,", "Aragonese=arg" )
$templanglist = StringReplace ($templanglist ,"asm,", "Assamese=asm" )
$templanglist = StringReplace ($templanglist ,"ava,", "Avaric=ava" )
$templanglist = StringReplace ($templanglist ,"ave,", "Avestan=ave" )
$templanglist = StringReplace ($templanglist ,"aym,", "Aymara=aym" )
$templanglist = StringReplace ($templanglist ,"aze,", "Azerbaijani=aze" )
$templanglist = StringReplace ($templanglist ,"bak,", "Bashkir=bak" )
$templanglist = StringReplace ($templanglist ,"bam,", "Bambara=bam" )
$templanglist = StringReplace ($templanglist ,"bel,", "Belarusian=bel" )
$templanglist = StringReplace ($templanglist ,"ben,", "Bengali=ben" )
$templanglist = StringReplace ($templanglist ,"bih,", "Bihari=bih" )
$templanglist = StringReplace ($templanglist ,"bis,", "Bislama=bis" )
$templanglist = StringReplace ($templanglist ,"bod,", "Tibetan=bod" )
$templanglist = StringReplace ($templanglist ,"bos,", "Bosnian=bos" )
$templanglist = StringReplace ($templanglist ,"bre,", "Breton=bre" )
$templanglist = StringReplace ($templanglist ,"bul,", "Bulgarian=bul" )
$templanglist = StringReplace ($templanglist ,"cat,", "Catalan=cat" )
$templanglist = StringReplace ($templanglist ,"ces,", "Czech=ces" )
$templanglist = StringReplace ($templanglist ,"cha,", "Chamorro=cha" )
$templanglist = StringReplace ($templanglist ,"che,", "Chechen=che" )
$templanglist = StringReplace ($templanglist ,"chu,", "Church Slavic=chu" )
$templanglist = StringReplace ($templanglist ,"chv,", "Chuvash=chv" )
$templanglist = StringReplace ($templanglist ,"cor,", "Cornish=cor" )
$templanglist = StringReplace ($templanglist ,"cos,", "Corsican=cos" )
$templanglist = StringReplace ($templanglist ,"cre,", "Cree=cre" )
$templanglist = StringReplace ($templanglist ,"cym,", "Welsh=cym" )
$templanglist = StringReplace ($templanglist ,"dan,", "Danish=dan" )
$templanglist = StringReplace ($templanglist ,"deu,", "German=deu" )
$templanglist = StringReplace ($templanglist ,"div,", "Divehi=div" )
$templanglist = StringReplace ($templanglist ,"dzo,", "Dzongkha=dzo" )
$templanglist = StringReplace ($templanglist ,"ell,", "Modern Greek=ell" )
$templanglist = StringReplace ($templanglist ,"eng,", "English=eng" )
$templanglist = StringReplace ($templanglist ,"epo,", "Esperanto=epo" )
$templanglist = StringReplace ($templanglist ,"est,", "Estonian=est" )
$templanglist = StringReplace ($templanglist ,"eus,", "Basque=eus" )
$templanglist = StringReplace ($templanglist ,"ewe,", "Ewe=ewe" )
$templanglist = StringReplace ($templanglist ,"fao,", "Faroese=fao" )
$templanglist = StringReplace ($templanglist ,"fas,", "Persian=fas" ) 
$templanglist = StringReplace ($templanglist ,"fij,", "Fijian=fij" )
$templanglist = StringReplace ($templanglist ,"fin,", "Finnish=fin" )
$templanglist = StringReplace ($templanglist ,"fra,", "French=fra" )
$templanglist = StringReplace ($templanglist ,"fry,", "Western Frisian=fry" )
$templanglist = StringReplace ($templanglist ,"ful,", "Fulah=ful" ) 
$templanglist = StringReplace ($templanglist ,"gla,", "Gaelic=gla" )
$templanglist = StringReplace ($templanglist ,"gle,", "Irish=gle" )
$templanglist = StringReplace ($templanglist ,"glg,", "Galician=glg" )
$templanglist = StringReplace ($templanglist ,"glv,", "Manx=glv" )
$templanglist = StringReplace ($templanglist ,"grn,", "Guaran=grn" )
$templanglist = StringReplace ($templanglist ,"guj,", "Gujarati=guj" )
$templanglist = StringReplace ($templanglist ,"hat,", "Haitian=hat" )
$templanglist = StringReplace ($templanglist ,"hau,", "Hausa=hau" )
$templanglist = StringReplace ($templanglist ,"heb,", "Modern Hebrew=heb" )
$templanglist = StringReplace ($templanglist ,"her,", "Herero=her" )
$templanglist = StringReplace ($templanglist ,"hin,", "Hindi=hin" )
$templanglist = StringReplace ($templanglist ,"hmo,", "Hiri Motu=hmo" )
$templanglist = StringReplace ($templanglist ,"hrv,", "Croatian=hrv" )
$templanglist = StringReplace ($templanglist ,"hun,", "Hungarian=hun" )
$templanglist = StringReplace ($templanglist ,"hye,", "Armenian=hye" )
$templanglist = StringReplace ($templanglist ,"ibo,", "Igbo=ibo" )
$templanglist = StringReplace ($templanglist ,"ido,", "Ido=ido" )
$templanglist = StringReplace ($templanglist ,"iii,", "Sichuan Yi=iii" )
$templanglist = StringReplace ($templanglist ,"iku,", "Inuktitut=iku" ) 
$templanglist = StringReplace ($templanglist ,"ile,", "Interlingue=ile" )
$templanglist = StringReplace ($templanglist ,"ina,", "Interlingua=ina" )
$templanglist = StringReplace ($templanglist ,"ind,", "Indonesian=ind" )
$templanglist = StringReplace ($templanglist ,"ipk,", "Inupiaq=ipk" ) 
$templanglist = StringReplace ($templanglist ,"isl,", "Icelandic=isl" )
$templanglist = StringReplace ($templanglist ,"ita,", "Italian=ita" )
$templanglist = StringReplace ($templanglist ,"jav,", "Javanese=jav" )
$templanglist = StringReplace ($templanglist ,"jpn,", "Japanese=jpn" )
$templanglist = StringReplace ($templanglist ,"kal,", "Kalaallisut=kal" )
$templanglist = StringReplace ($templanglist ,"kan,", "Kannada=kan" )
$templanglist = StringReplace ($templanglist ,"kas,", "Kashmiri=kas" )
$templanglist = StringReplace ($templanglist ,"kat,", "Georgian=kat" )
$templanglist = StringReplace ($templanglist ,"kau,", "Kanuri=kau" ) 
$templanglist = StringReplace ($templanglist ,"kaz,", "Kazakh=kaz" )
$templanglist = StringReplace ($templanglist ,"khm,", "Central Khmer=khm" )
$templanglist = StringReplace ($templanglist ,"kik,", "Kikuyu=kik" )
$templanglist = StringReplace ($templanglist ,"kin,", "Kinyarwanda=kin" )
$templanglist = StringReplace ($templanglist ,"kir,", "Kirghiz=kir" )
$templanglist = StringReplace ($templanglist ,"kom,", "Komi=kom" ) 
$templanglist = StringReplace ($templanglist ,"kon,", "Kongo=kon" )
$templanglist = StringReplace ($templanglist ,"kor,", "Korean=kor" )
$templanglist = StringReplace ($templanglist ,"kua,", "Kwanyama=kua" )
$templanglist = StringReplace ($templanglist ,"kur,", "Kurdish=kur" ) 
$templanglist = StringReplace ($templanglist ,"lao,", "Lao=lao" )
$templanglist = StringReplace ($templanglist ,"lat,", "Latin=lat" )
$templanglist = StringReplace ($templanglist ,"lav,", "Latvian=lav" )
$templanglist = StringReplace ($templanglist ,"lim,", "Limburgish=lim" )
$templanglist = StringReplace ($templanglist ,"lin,", "Lingala=lin" )
$templanglist = StringReplace ($templanglist ,"lit,", "Lithuanian=lit" )
$templanglist = StringReplace ($templanglist ,"ltz,", "Luxembourgish=ltz" )
$templanglist = StringReplace ($templanglist ,"lub,", "Luba-Katanga=lub" )
$templanglist = StringReplace ($templanglist ,"lug,", "Ganda=lug" )
$templanglist = StringReplace ($templanglist ,"mah,", "Marshallese=mah" )
$templanglist = StringReplace ($templanglist ,"mal,", "Malayalam=mal" )
$templanglist = StringReplace ($templanglist ,"mar,", "Marathi=mar" )
$templanglist = StringReplace ($templanglist ,"mkd,", "Macedonian=mkd" )
$templanglist = StringReplace ($templanglist ,"mlg,", "Malagasy=mlg" )
$templanglist = StringReplace ($templanglist ,"mlt,", "Maltese=mlt" )
$templanglist = StringReplace ($templanglist ,"mon,", "Mongolian=mon" ) 
$templanglist = StringReplace ($templanglist ,"mri,", "M?ori=mri" )
$templanglist = StringReplace ($templanglist ,"msa,", "Malay=msa" ) 
$templanglist = StringReplace ($templanglist ,"mya,", "Burmese=mya" )
$templanglist = StringReplace ($templanglist ,"nau,", "Nauru=nau" )
$templanglist = StringReplace ($templanglist ,"nav,", "Navajo=nav" )
$templanglist = StringReplace ($templanglist ,"nbl,", "South Ndebele=nbl" )
$templanglist = StringReplace ($templanglist ,"nde,", "North Ndebele=nde" )
$templanglist = StringReplace ($templanglist ,"ndo,", "Ndonga=ndo" )
$templanglist = StringReplace ($templanglist ,"nep,", "Nepali=nep" )
$templanglist = StringReplace ($templanglist ,"nld,", "Dutch Flemish=nld" )
$templanglist = StringReplace ($templanglist ,"nno,", "Norwegian Nynorsk=nno" )
$templanglist = StringReplace ($templanglist ,"nob,", "Norwegian Bokmal=nob" )
$templanglist = StringReplace ($templanglist ,"nor,", "Norwegian=nor" ) 
$templanglist = StringReplace ($templanglist ,"nya,", "Chichewa=nya" )
$templanglist = StringReplace ($templanglist ,"oci,", "Occitan =oci" )
$templanglist = StringReplace ($templanglist ,"oji,", "Ojibwa=oji" ) 
$templanglist = StringReplace ($templanglist ,"ori,", "Oriya=ori" )
$templanglist = StringReplace ($templanglist ,"orm,", "Oromo=orm" ) 
$templanglist = StringReplace ($templanglist ,"oss,", "Ossetian=oss" )
$templanglist = StringReplace ($templanglist ,"pan,", "Panjabi=pan" )
$templanglist = StringReplace ($templanglist ,"pli,", "Pali=pli" )
$templanglist = StringReplace ($templanglist ,"pol,", "Polish=pol" )
$templanglist = StringReplace ($templanglist ,"por,", "Portuguese=por" )
$templanglist = StringReplace ($templanglist ,"pus,", "Pashto=pus" )
$templanglist = StringReplace ($templanglist ,"que,", "Quechua=que" )
$templanglist = StringReplace ($templanglist ,"roh,", "Romansh=roh" )
$templanglist = StringReplace ($templanglist ,"ron,", "Romanian=ron" )
$templanglist = StringReplace ($templanglist ,"run,", "Rundi=run" )
$templanglist = StringReplace ($templanglist ,"rus,", "Russian=rus" )
$templanglist = StringReplace ($templanglist ,"sag,", "Sango=sag" )
$templanglist = StringReplace ($templanglist ,"san,", "Sanskrit=san" )
$templanglist = StringReplace ($templanglist ,"sin,", "Sinhala=sin" )
$templanglist = StringReplace ($templanglist ,"slk,", "Slovak=slk" )
$templanglist = StringReplace ($templanglist ,"slv,", "Slovene=slv" )
$templanglist = StringReplace ($templanglist ,"sme,", "Northern Sami=sme" )
$templanglist = StringReplace ($templanglist ,"smo,", "Samoan=smo" )
$templanglist = StringReplace ($templanglist ,"sna,", "Shona=sna" )
$templanglist = StringReplace ($templanglist ,"snd,", "Sindhi=snd" )
$templanglist = StringReplace ($templanglist ,"som,", "Somali=som" )
$templanglist = StringReplace ($templanglist ,"sot,", "Southern Sotho=sot" )
$templanglist = StringReplace ($templanglist ,"spa,", "Spanish=spa" )
$templanglist = StringReplace ($templanglist ,"sqi,", "Albanian=sqi" )
$templanglist = StringReplace ($templanglist ,"srd,", "Sardinian=srd" )
$templanglist = StringReplace ($templanglist ,"srp,", "Serbian=srp" )
$templanglist = StringReplace ($templanglist ,"ssw,", "Swati=ssw" )
$templanglist = StringReplace ($templanglist ,"sun,", "Sundanese=sun" )
$templanglist = StringReplace ($templanglist ,"swa,", "Swahili=swa" )
$templanglist = StringReplace ($templanglist ,"swe,", "Swedish=swe" )
$templanglist = StringReplace ($templanglist ,"tah,", "Tahitian=tah" )
$templanglist = StringReplace ($templanglist ,"tam,", "Tamil=tam" )
$templanglist = StringReplace ($templanglist ,"tat,", "Tatar=tat" )
$templanglist = StringReplace ($templanglist ,"tel,", "Telugu=tel" )
$templanglist = StringReplace ($templanglist ,"tgk,", "Tajik=tgk" )
$templanglist = StringReplace ($templanglist ,"tgl,", "Tagalog=tgl" )
$templanglist = StringReplace ($templanglist ,"tha,", "Thai=tha" )
$templanglist = StringReplace ($templanglist ,"tir,", "Tigrinya=tir" )
$templanglist = StringReplace ($templanglist ,"ton,", "Tonga=ton" )
$templanglist = StringReplace ($templanglist ,"tsn,", "Tswana=tsn" )
$templanglist = StringReplace ($templanglist ,"tso,", "Tsonga=tso" )
$templanglist = StringReplace ($templanglist ,"tuk,", "Turkmen=tuk" )
$templanglist = StringReplace ($templanglist ,"tur,", "Turkish=tur" )
$templanglist = StringReplace ($templanglist ,"twi,", "Twi=twi" )
$templanglist = StringReplace ($templanglist ,"uig,", "Uighur=uig" )
$templanglist = StringReplace ($templanglist ,"ukr,", "Ukrainian=ukr" )
$templanglist = StringReplace ($templanglist ,"urd,", "Urdu=urd" )
$templanglist = StringReplace ($templanglist ,"uzb,", "Uzbek=uzb" )
$templanglist = StringReplace ($templanglist ,"ven,", "Venda=ven" )
$templanglist = StringReplace ($templanglist ,"vie,", "Vietnamese=vie" )
$templanglist = StringReplace ($templanglist ,"vol,", "VolapYk=vol" )
$templanglist = StringReplace ($templanglist ,"wln,", "Walloon=wln" )
$templanglist = StringReplace ($templanglist ,"wol,", "Wolof=wol" )
$templanglist = StringReplace ($templanglist ,"xho,", "Xhosa=xho" )
$templanglist = StringReplace ($templanglist ,"yid,", "Yiddish=yid" ) 
$templanglist = StringReplace ($templanglist ,"yor,", "Yoruba=yor" )
$templanglist = StringReplace ($templanglist ,"zha,", "Zhuang=zha" ) 
$templanglist = StringReplace ($templanglist ,"zho,", "Chinese=zho" ) 
$templanglist = StringReplace ($templanglist ,"zul,", "Zulu=zul" )

; ===============================================================================================================================
; Writing final lang-list.txt file
; ===============================================================================================================================
FileWrite ("langlist.txt", $templanglist )

; ===============================================================================================================================
; Removing used lslang.txt
; ===============================================================================================================================
FileDelete ("lslang.txt")

; ===============================================================================================================================
; And Bye
; ===============================================================================================================================
Exit